<template>
  <div class="app-container">
  <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
    <el-form-item label="姓名" prop="a0101">
      <el-input
        v-model="queryParams.a0101"
        placeholder="请输入姓名"
        clearable
        size="small"
        @keyup.enter.native="handleQuery"
      />
    </el-form-item>
    <el-form-item label="性别" prop="a0104">
      <el-select v-model="queryParams.a0104" placeholder="请选择性别" clearable size="small">
        <el-option
          v-for="dict in a0104Options"
          :key="dict.dictValue"
          :label="dict.dictLabel"
          :value="dict.dictValue"
        />
      </el-select>
    </el-form-item>
    <el-form-item label="政治面貌" prop="a0141">
      <el-select v-model="queryParams.a0141" placeholder="请选择政治面貌" clearable size="small">
        <el-option
          v-for="dict in a0141Options"
          :key="dict.dictValue"
          :label="dict.dictLabel"
          :value="dict.dictValue"
        />
      </el-select>
    </el-form-item>
    <el-form-item label="教师编号" prop="a0199">
      <el-input
        v-model="queryParams.a0199"
        placeholder="请输入教师编号"
        clearable
        size="small"
        @keyup.enter.native="handleQuery"
      />
    </el-form-item>
    <el-form-item>
      <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
      <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
    </el-form-item>
  </el-form>
    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="课程名称" prop="coursename">
        <el-input
          v-model="queryParams.coursename"
          placeholder="请输入课程名称"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="班级名称" prop="classname">
        <el-input
          v-model="queryParams.classname"
          placeholder="请输入班级名称"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
    </el-form>
    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="评价班级名称" prop="classname">
        <el-input
          v-model="queryParams.classname"
          placeholder="请输入评价班级名称"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="评价日期" prop="evaluationdate">
        <el-date-picker clearable size="small"
                        v-model="queryParams.evaluationdate"
                        type="date"
                        value-format="yyyy-MM-dd"
                        placeholder="选择评价日期">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="评价等级" prop="evaluationlevel">
        <el-input
          v-model="queryParams.evaluationlevel"
          placeholder="请输入评价等级"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="评价分数" prop="evaluationscore">
        <el-input
          v-model="queryParams.evaluationscore"
          placeholder="请输入评价分数"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
    </el-form>
    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="编号" prop="itemnumber">
        <el-input
          v-model="queryParams.itemnumber"
          placeholder="请输入项目编号、著作权编号、获奖编号"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="名称" prop="topic">
        <el-input
          v-model="queryParams.topic"
          placeholder="请输入论文题目、著作名称、著作权名称、结题/验收项目名、奖励名称"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="通讯作者" prop="correspondingauthor">
        <el-input
          v-model="queryParams.correspondingauthor"
          placeholder="请输入通讯作者"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="类别" prop="category">
        <el-input
          v-model="queryParams.category"
          placeholder="请输入刊物类型、著作权类型、奖励类别"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="发表/出版时间" prop="issuingtime">
        <el-date-picker clearable size="small"
                        v-model="queryParams.issuingtime"
                        type="date"
                        value-format="yyyy-MM-dd"
                        placeholder="选择发表/出版时间">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="单位排名" prop="ranklevel">
        <el-input
          v-model="queryParams.ranklevel"
          placeholder="请输入单位排名"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
    </el-form>
    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="教师ID" prop="a00">
        <el-input
          v-model="queryParams.a00"
          placeholder="请输入教师ID"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="作者类型" prop="authortype">
        <el-input
          v-model="queryParams.authortype"
          placeholder="请输入作者类型"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="作者姓名" prop="authorname">
        <el-input
          v-model="queryParams.authorname"
          placeholder="请输入作者姓名"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="性别" prop="a0104">
        <el-select v-model="queryParams.a0104" placeholder="请选择性别" clearable size="small">
          <el-option
            v-for="dict in a0104Options"
            :key="dict.dictValue"
            :label="dict.dictLabel"
            :value="dict.dictValue"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="专业技术资格名称" prop="a0601">
        <el-select v-model="queryParams.a0601" placeholder="请选择专业技术资格名称" clearable size="small">
          <el-option
            v-for="dict in a0601Options"
            :key="dict.dictValue"
            :label="dict.dictLabel"
            :value="dict.dictValue"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="是否是通讯作者" prop="commuauthor">
        <el-select v-model="queryParams.commuauthor" placeholder="请选择是否是通讯作者" clearable size="small">
          <el-option
            v-for="dict in commuauthorOptions"
            :key="dict.dictValue"
            :label="dict.dictLabel"
            :value="dict.dictValue"
          />
        </el-select>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
import { exportPerson, listPerson} from "@/api/teacher/person";
import {listCourse} from "@/api/teacher/course";
import {listEvaluate} from "@/api/teacher/evaluate";
import {listCommon} from "@/api/teacher/common";
import {listAuthor} from "@/api/teacher/author";
export default {
  name: "index",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 教师基本信息表格数据
      personList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 性别字典
      a0104Options: [],
      // 籍贯字典
      a0111bOptions: [],
      // 出生地字典
      a0114bOptions: [],
      // 民族字典
      a0117Options: [],
      // 健康状况字典
      a0127Options: [],
      // 婚姻状况字典
      a0131Options: [],
      // 政治面貌字典
      a0141Options: [],
      // 户籍所在地字典
      a0181aOptions: [],
      // 有效证件类别字典
      a0183Options: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        a0101: null,
        a0104: null,
        a0141: null,
        a0199: null,
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        a00: [
          { required: true, message: "人员标识符不能为空", trigger: "blur" }
        ],
        a0101: [
          { required: true, message: "姓名不能为空", trigger: "blur" }
        ],
      }
    };
  },
  created() {
    this.getList();
    this.getDicts("sys_user_sex").then(response => {
      this.a0104Options = response.data;
    });
    this.getDicts("sys_person_place").then(response => {
      this.a0111bOptions = response.data;
    });
    this.getDicts("sys_person_place").then(response => {
      this.a0114bOptions = response.data;
    });
    this.getDicts("sys_person_nationality").then(response => {
      this.a0117Options = response.data;
    });
    this.getDicts("sys_person_health").then(response => {
      this.a0127Options = response.data;
    });
    this.getDicts("sys_person_marry").then(response => {
      this.a0131Options = response.data;
    });
    this.getDicts("sys_person_landscape").then(response => {
      this.a0141Options = response.data;
    });
    this.getDicts("sys_person_place").then(response => {
      this.a0181aOptions = response.data;
    });
    this.getDicts("sys_person_card").then(response => {
      this.a0183Options = response.data;
    });
  },
  methods: {
    /** 查询教师基本信息列表 */
    getList() {
      this.loading = true;
      listPerson(this.queryParams).then(response => {
        this.personList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
      listCourse(this.queryParams).then(response => {
        this.courseList = response.rows;
        this.total = response.total;
        this.loading = false;
        listEvaluate(this.queryParams).then(response => {
          this.evaluateList = response.rows;
          this.total = response.total;
          this.loading = false;
        });
        listCommon(this.queryParams).then(response => {
          this.commonList = response.rows;
          this.total = response.total;
          this.loading = false;
        });
        listAuthor(this.queryParams).then(response => {
          this.authorList = response.rows;
          this.total = response.total;
          this.loading = false;
        });

      });
    },
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        a00: null,
        userId: null,
        a0101: null,
        a0104: null,
        a0107: null,
        a0111b: null,
        a0114b: null,
        a0117: null,
        a0127: null,
        a0131: null,
        a0134: null,
        a0141: null,
        a0181a: null,
        a0183: null,
        a0184: null,
        a0199: null,
        zdyxa0106: null,
        createBy: null,
        createTime: null,
        updateBy: null,
        updateTime: null,
        delFlag: null,
        remark: null,
        zdyxa0109: null,
        zdyxa01110: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.a00)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 导出按钮操作 */
    handleExport() {
      const queryParams = this.queryParams;
      this.$confirm('是否确认导出所有教师基本信息数据项?', "警告", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      }).then(function() {
        return exportPerson(queryParams);
      }).then(response => {
        this.download(response.msg);
      })
    }
  }
}
</script>

<style scoped>

</style>
